# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
project(libwebp)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in
               ${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h
               @ONLY)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})

file(GLOB lib_srcs src/dec/*.c src/demux/*.c src/dsp/*.c src/enc/*.c src/mux/*.c src/utils/*.c src/webp/*.c)
file(GLOB lib_hdrs src/dec/*.h src/demux/*.h src/dsp/*.h src/enc/*.h src/mux/*.h src/utils/*.h src/webp/*.h)

# FIXIT
if(ANDROID AND ARMEABI_V7A AND NOT NEON)
  foreach(file ${lib_srcs})
    if("${file}" MATCHES "_neon.c")
#      set_source_files_properties("${file}" COMPILE_FLAGS "-mfpu=neon")
    endif()
  endforeach()
endif()

# FIX for quant.h - requires C99 for() loops
if(${_varname})
#  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
endif()

# ----------------------------------------------------------------------------------
#         Define the library target:
# ----------------------------------------------------------------------------------

if(NOT OPENCV_DISABLE_THREAD_SUPPORT)
#  add_definitions(-DWEBP_USE_THREAD)
endif()

add_library(webp SHARED ${lib_srcs} ${lib_hdrs})

target_link_libraries(webp PUBLIC libz.so)

#target_link_directories(webp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)



